import { defineView } from "@/routers/tools.mjs";

/**
 * @abstract
 * @implements {ng.IController}
 */
class SuperLifeCycleHooksCtrl {
  /**
   * @type {string[]}
   */
  static $inject = [];

  $onInit() {
    console.log(SuperLifeCycleHooksCtrl.name, this.$onInit.name);
  }

  $onDestroy() {
    console.log(SuperLifeCycleHooksCtrl.name, this.$onDestroy.name);
  }
}

class LifeCycleHooksCtrl extends SuperLifeCycleHooksCtrl {
  /**
   * @override
   */
  static $inject = ["$scope"];

  /**
   * @param {ng.IScope} $scope
   */
  constructor($scope) {
    super();
    this.$scope = $scope;
    // this.$inject = angular.injector();
  }

  /**
   * @override
   */
  $onInit() {
    console.log(LifeCycleHooksCtrl.name, this.$onInit.name);
    // super.$onInit()
  }

  /**
   * @override
   */
  $onDestroy() {
    console.log(LifeCycleHooksCtrl.name, this.$onDestroy.name);
    // super.$onDestroy()
  }

  handleClick() {
    console.log(this);
  }
}

/**
 * @type {DefineView}
 */
const ParentControllerView = defineView({
  controller: LifeCycleHooksCtrl,
  controllerAs: "ParentController",
  template: /* HTML */ html`
    <!-- TODO: -->
    <div class="parent-controller">
      ${DebugButtonHTML("ParentController")}
      <div class="parent-controller__container">
        <div class="parent-controller__item">
          <div class="parent-controller__item__title">
            <span class="parent-controller__item__title__text"> 父控制器 </span>
          </div>
          <div class="parent-controller__item__content">
            <span class="parent-controller__item__content__text">
              父控制器
            </span>
          </div>
        </div>
      </div>
    </div>
  `,
});

export default ParentControllerView;
